diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp index 005bcd6b6..d7ea6af0a 100644 --- a/src/app/commands/cmd_export_sprite_sheet.cpp +++ b/src/app/commands/cmd_export_sprite_sheet.cpp @@ -92,7 +92,7 @@ public: hbox1->addChild(hbox2); hbox2->addChild(&m_export); hbox2->addChild(&m_cancel); - jwidget_set_min_size(&m_export, 60, 0); + m_export.setMinSize(gfx::Size(60, 0)); m_grid.addChildInCell(hbox1, 4, 1, 0); } diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp index 981021cb2..2958dfb2a 100644 --- a/src/app/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -90,7 +90,7 @@ public: hbox1->addChild(hbox2); hbox2->addChild(&m_import); hbox2->addChild(&m_cancel); - jwidget_set_min_size(&m_import, 60, 0); + m_import.setMinSize(gfx::Size(60, 0)); m_grid.addChildInCell(hbox1, 4, 1, 0); } diff --git a/src/app/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp index 3a969b0ba..8b69b17e5 100644 --- a/src/app/commands/cmd_layer_properties.cpp +++ b/src/app/commands/cmd_layer_properties.cpp @@ -74,7 +74,7 @@ void LayerPropertiesCommand::onExecute(Context* context) button_ok->Click.connect(Bind(&Window::closeWindow, window.get(), button_ok)); button_cancel->Click.connect(Bind(&Window::closeWindow, window.get(), button_cancel)); - jwidget_set_min_size(entry_name, 128, 0); + entry_name->setMinSize(gfx::Size(128, 0)); entry_name->setExpansive(true); box2->addChild(label_name); diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index a6ccf9e5c..88134e1ce 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -101,7 +101,7 @@ void NewLayerCommand::onExecute(Context* context) base::UniquePtr window(app::load_widget("new_layer.xml", "new_layer")); Widget* name_widget = app::find_widget(window, "name"); name_widget->setText(name.c_str()); - jwidget_set_min_size(name_widget, 128, 0); + name_widget->setMinSize(gfx::Size(128, 0)); window->openWindowInForeground(); diff --git a/src/app/commands/filters/cmd_color_curve.cpp b/src/app/commands/filters/cmd_color_curve.cpp index bae19130e..6f0b0dd38 100644 --- a/src/app/commands/filters/cmd_color_curve.cpp +++ b/src/app/commands/filters/cmd_color_curve.cpp @@ -60,7 +60,7 @@ public: { m_view.attachToView(&m_editor); m_view.setExpansive(true); - jwidget_set_min_size(&m_view, 128, 64); + m_view.setMinSize(gfx::Size(128, 64)); getContainer()->addChild(&m_view); diff --git a/src/app/console.cpp b/src/app/console.cpp index 658b42734..c8b6d33a7 100644 --- a/src/app/console.cpp +++ b/src/app/console.cpp @@ -68,7 +68,7 @@ Console::Console() view->attachToView(textbox); - jwidget_set_min_size(button, 60, 0); + button->setMinSize(gfx::Size(60, 0)); grid->addChildInCell(view, 1, 1, JI_HORIZONTAL | JI_VERTICAL); grid->addChildInCell(button, 1, 1, JI_CENTER); diff --git a/src/app/ui/file_selector.cpp b/src/app/ui/file_selector.cpp index dd8098dca..74edd11d5 100644 --- a/src/app/ui/file_selector.cpp +++ b/src/app/ui/file_selector.cpp @@ -299,7 +299,7 @@ std::string FileSelector::show(const std::string& title, PRINTF("start_folder_path = %s (%p)\n", start_folder_path.c_str(), start_folder); - jwidget_set_min_size(this, JI_SCREEN_W*9/10, JI_SCREEN_H*9/10); + setMinSize(gfx::Size(JI_SCREEN_W*9/10, JI_SCREEN_H*9/10)); remapWindow(); centerWindow(); diff --git a/src/app/ui/status_bar.cpp b/src/app/ui/status_bar.cpp index 85a27a5a6..3fd32a636 100644 --- a/src/app/ui/status_bar.cpp +++ b/src/app/ui/status_bar.cpp @@ -207,7 +207,7 @@ StatusBar::StatusBar() ICON_NEW(m_b_last, PART_ANI_LAST, ACTION_LAST); m_slider->Change.connect(Bind(&slider_change_hook, m_slider)); - jwidget_set_min_size(m_slider, JI_SCREEN_W/5, 0); + m_slider->setMinSize(gfx::Size(JI_SCREEN_W/5, 0)); box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale()); box2->noBorderNoChildSpacing(); diff --git a/src/app/widget_loader.cpp b/src/app/widget_loader.cpp index 7d9788114..d5ed8dd7b 100644 --- a/src/app/widget_loader.cpp +++ b/src/app/widget_loader.cpp @@ -439,14 +439,14 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget height || minheight) { int w = (width || minwidth) ? ustrtol(width ? width: minwidth, NULL, 10): 0; int h = (height || minheight) ? ustrtol(height ? height: minheight, NULL, 10): 0; - jwidget_set_min_size(widget, w*jguiscale(), h*jguiscale()); + widget->setMinSize(gfx::Size(w*jguiscale(), h*jguiscale())); } if (width || maxwidth || height || maxheight) { int w = (width || maxwidth) ? strtol(width ? width: maxwidth, NULL, 10): INT_MAX; int h = (height || maxheight) ? strtol(height ? height: maxheight, NULL, 10): INT_MAX; - jwidget_set_max_size(widget, w*jguiscale(), h*jguiscale()); + widget->setMaxSize(gfx::Size(w*jguiscale(), h*jguiscale())); } if (!root) diff --git a/src/ui/alert.cpp b/src/ui/alert.cpp index 4ae034ffb..8a03b3f59 100644 --- a/src/ui/alert.cpp +++ b/src/ui/alert.cpp @@ -144,7 +144,7 @@ void Alert::processString(char* buf, std::vector& labels, std::vectorsetMinSize(gfx::Size(60*jguiscale(), 0)); buttons.push_back(button_widget); usprintf(buttonId, "button-%lu", buttons.size()); diff --git a/src/ui/combobox.cpp b/src/ui/combobox.cpp index ff443b904..074fbd6ed 100644 --- a/src/ui/combobox.cpp +++ b/src/ui/combobox.cpp @@ -505,12 +505,12 @@ void ComboBox::openListBox() Widget* viewport = view->getViewport(); int size = getItemCount(); - jwidget_set_min_size - (viewport, - m_button->getBounds().x2() - m_entry->getBounds().x - view->border_width.l - view->border_width.r, - +viewport->border_width.t - +(2*jguiscale()+m_listbox->getTextHeight())*MID(1, size, 16)+ - +viewport->border_width.b); + viewport->setMinSize + (gfx::Size( + m_button->getBounds().x2() - m_entry->getBounds().x - view->border_width.l - view->border_width.r, + +viewport->border_width.t + +(2*jguiscale()+m_listbox->getTextHeight())*MID(1, size, 16)+ + +viewport->border_width.b)); m_window->addChild(view); view->attachToView(m_listbox); diff --git a/src/ui/grid_ui_unittest.cpp b/src/ui/grid_ui_unittest.cpp index 00737c4dd..03a225976 100644 --- a/src/ui/grid_ui_unittest.cpp +++ b/src/ui/grid_ui_unittest.cpp @@ -30,8 +30,8 @@ TEST(JGrid, Simple2x1Grid) Widget* w1 = new Widget(kGenericWidget); Widget* w2 = new Widget(kGenericWidget); - jwidget_set_min_size(w1, 10, 10); - jwidget_set_min_size(w2, 10, 10); + w1->setMinSize(gfx::Size(10, 10)); + w2->setMinSize(gfx::Size(10, 10)); grid->addChildInCell(w1, 1, 1, 0); grid->addChildInCell(w2, 1, 1, 0); @@ -69,8 +69,8 @@ TEST(JGrid, Expand2ndWidget) Widget* w1 = new Widget(kGenericWidget); Widget* w2 = new Widget(kGenericWidget); - jwidget_set_min_size(w1, 20, 20); - jwidget_set_min_size(w2, 10, 10); + w1->setMinSize(gfx::Size(20, 20)); + w2->setMinSize(gfx::Size(10, 10)); grid->addChildInCell(w1, 1, 1, 0); grid->addChildInCell(w2, 1, 1, JI_HORIZONTAL | JI_TOP); @@ -102,8 +102,8 @@ TEST(JGrid, SameWidth2x1Grid) Widget* w1 = new Widget(kGenericWidget); Widget* w2 = new Widget(kGenericWidget); - jwidget_set_min_size(w1, 20, 20); - jwidget_set_min_size(w2, 10, 10); + w1->setMinSize(gfx::Size(20, 20)); + w2->setMinSize(gfx::Size(10, 10)); grid->addChildInCell(w1, 1, 1, 0); grid->addChildInCell(w2, 1, 1, 0); @@ -166,10 +166,10 @@ TEST(JGrid, Intrincate3x3Grid) Widget* w3 = new Widget(kGenericWidget); Widget* w4 = new Widget(kGenericWidget); - jwidget_set_min_size(w1, 10, 10); - jwidget_set_min_size(w2, 10, 10); - jwidget_set_min_size(w3, 10, 10); - jwidget_set_min_size(w4, 10, 10); + w1->setMinSize(gfx::Size(10, 10)); + w2->setMinSize(gfx::Size(10, 10)); + w3->setMinSize(gfx::Size(10, 10)); + w4->setMinSize(gfx::Size(10, 10)); grid->addChildInCell(w1, 1, 1, 0); grid->addChildInCell(w2, 2, 1, JI_HORIZONTAL); diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index 6821c8d20..f69ecf8f2 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -850,20 +850,16 @@ void Widget::getTextIconInfo( SETRECT(icon); } -void jwidget_set_min_size(Widget* widget, int w, int h) +void Widget::setMinSize(const gfx::Size& sz) { - ASSERT_VALID_WIDGET(widget); - - widget->min_w = w; - widget->min_h = h; + min_w = sz.w; + min_h = sz.h; } -void jwidget_set_max_size(Widget* widget, int w, int h) +void Widget::setMaxSize(const gfx::Size& sz) { - ASSERT_VALID_WIDGET(widget); - - widget->max_w = w; - widget->max_h = h; + max_w = sz.w; + max_h = sz.h; } void Widget::flushRedraw() diff --git a/src/ui/widget.h b/src/ui/widget.h index 158a9807e..e1e0bf654 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -25,7 +25,6 @@ #define ASSERT_VALID_WIDGET(widget) ASSERT((widget) != NULL) struct FONT; -struct BITMAP; namespace ui { @@ -40,15 +39,6 @@ namespace ui { class Theme; class Window; - WidgetType register_widget_type(); - - // Position and geometry - - void jwidget_set_min_size(Widget* widget, int w, int h); - void jwidget_set_max_size(Widget* widget, int w, int h); - - ////////////////////////////////////////////////////////////////////// - class Widget : public Component { public: WidgetType type; // widget's type @@ -264,6 +254,9 @@ namespace ui { // generating recursive onResize() events. void setBoundsQuietly(const gfx::Rect& rc); + void setMinSize(const gfx::Size& sz); + void setMaxSize(const gfx::Size& sz); + gfx::Border getBorder() const; void setBorder(const gfx::Border& border); @@ -396,6 +389,8 @@ namespace ui { bool m_transparent; }; + WidgetType register_widget_type(); + } // namespace ui #endif