27 #ifndef NEIGHBOR_SELECT_PANEL_H
28 #define NEIGHBOR_SELECT_PANEL_H
36 template <
class CC, u32 R>
50 NEIGHBOR_SELECT_MANY = 0,
52 }NeighborhoodSelectMode;
63 inline u32 GetCellSize()
const
65 return Super::m_bigText ?
70 inline FontAsset GetFontAsset()
const
72 return Super::m_bigText ?
73 FONT_ASSET_HELPPANEL_BIG :
74 FONT_ASSET_HELPPANEL_SMALL;
77 NeighborhoodSelectMode m_selectMode;
85 static const u32 ENABLED_COLOR = 0xff20a020;
92 void FlipBit(u32 bitNum)
104 void SetBit(u32 bitNum)
117 void ClearBit(u32 bitNum)
126 np->ClearBit(bitNum);
130 bool IsBitOn(u32 bitNum)
132 return m_bitField.
ReadBit(bitNum);
137 s32 offset = R * GetCellSize() + BORDER_SIZE;
143 renderPt.
Set(offset + (GetCellSize() - 1) * n.GetPoint(i).GetX(),
144 offset + (GetCellSize() - 1) * n.GetPoint(i).GetY());
151 case NEIGHBOR_SELECT_MANY:
155 case NEIGHBOR_SELECT_ONE:
159 d.
FillRect(renderPt.
GetX() + 1, renderPt.
GetY() + 1, GetCellSize() - 2, GetCellSize() - 2);
165 UPoint textLoc(R * (GetCellSize() + 1) * 2 + GetCellSize() + BORDER_SIZE,
166 R * (GetCellSize() - 1) + BORDER_SIZE);
180 m_selectMode(NEIGHBOR_SELECT_MANY),
188 Panel::SetDesiredSize(500, (2 * BORDER_SIZE) + (R * 2 + 1) * GetCellSize());
194 Super::SetParameter(pb);
201 FAIL(ILLEGAL_ARGUMENT);
204 u64 ngb = np->GetValue();
206 LOG.
Debug(
"Neighborhood initted to %@", np);
209 void SetSelectMode(NeighborhoodSelectMode mode)
216 void SetText(
const char* text)
224 d.
FillRect(0, 0, Panel::GetDimensions().GetX(), Panel::GetDimensions().GetY());
232 if(event.m_event.type == SDL_MOUSEBUTTONDOWN &&
233 event.m_event.button.button == SDL_BUTTON_LEFT)
235 s32 offset = R * GetCellSize() + BORDER_SIZE;
238 SPoint clickPt(event.GetAt().
GetX() - Panel::GetRenderPoint().GetX(),
239 event.GetAt().GetY() - Panel::GetRenderPoint().GetY());
244 buttonRect.
SetPosition(
SPoint(offset + (GetCellSize() - 1) * n.GetPoint(i).GetX(),
245 offset + (GetCellSize() - 1) * n.GetPoint(i).GetY()));
251 case NEIGHBOR_SELECT_MANY:
254 case NEIGHBOR_SELECT_ONE:
255 m_selectedOne.
Set(n.GetPoint(i).GetX(), n.GetPoint(i).GetY());
u32 GetFirstIndex(const u32 radius) const
Definition: MDist.h:112
void Clear()
Definition: BitVector.tcc:26
Definition: Parameter.h:43
u32 GetLastIndex(const u32 radius) const
Definition: MDist.h:129
u32 SetForeground(const u32 color)
Definition: Drawing.h:188
void SetSize(const UPoint &newSize)
Definition: Rect.h:229
void WriteBit(u32 idx, bool bit)
Definition: BitVector.tcc:41
void SetPosition(const SPoint &newPos)
Definition: Rect.h:167
u32 SetForeground(const u32 color)
Definition: Panel.h:256
void Set(T x, T y)
Definition: Point.tcc:183
T GetY() const
Definition: Point.tcc:40
Definition: ParameterController.h:40
void BlitBackedText(const char *message, UPoint loc, UPoint size)
Definition: Drawing.cpp:233
SPoint GetTextSize(const char *message)
Definition: Drawing.cpp:201
u32 SetBackground(const u32 color)
Definition: Drawing.h:170
u32 GetForeground() const
Definition: Panel.h:248
bool Contains(const SPoint &point)
Definition: Rect.h:127
void Debug(const char *format,...)
Definition: Logger.h:301
virtual void PaintComponent(Drawing &d)
Definition: NeighborSelectPanel.h:221
static MDist< R > & get()
Definition: MDist.tcc:193
bool ReadBit(u32 idx)
Definition: BitVector.tcc:65
void FillRect(int x, int y, int w, int h) const
Definition: Drawing.cpp:115
#define EVENT_WINDOW_SITES(radius)
Definition: MDist.h:46
void WriteLong(const u32 startIdx, const u32 length, const u64 value)
Definition: BitVector.tcc:87
TTF_Font * SetFont(TTF_Font *newFont)
Definition: Drawing.h:209
virtual bool Handle(MouseButtonEvent &event)
Definition: NeighborSelectPanel.h:230
Definition: NeighborSelectPanel.h:37
Definition: Parameter.h:715
T GetX() const
Definition: Point.tcc:34